﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace zUfDsl
{
    public static class DbExt
    {

        #region 获取值
        /// <summary>
        /// 获取值
        /// </summary>
        public static DataTable GetDataTable(this ModelUF.U8DataContext db, string sql)
        {
            if (db.Connection.State == System.Data.ConnectionState.Closed) { db.Connection.Open(); }
            var cmd = db.Connection.CreateCommand();
            if (db.Transaction != null) { cmd.Transaction = db.Transaction; }
            cmd.CommandText = sql;
            var rs = cmd.ExecuteReader();
            var dt = new DataTable();
            dt.Load(rs);
            return dt;
        }
        #endregion       
    }
}
